from typing import List


class Solution:
    def coinChange(self, coins: List[int], amount: int) -> int:
        dp = [0]*(amount+1)
        for i in range(1, amount+1):
            curr = amount+1
            for coin in coins:
                if i-coin >= 0:
                    curr = min(curr, 1+dp[i-coin])
            dp[i] = curr
        
        return dp[amount] if dp[amount] != amount+1 else -1
